<template>
  <div class="main_content">
    <father-title></father-title>
    <div class="contentBox">
      <header-tabs>
        <template slot="tabs">
          <div>
            <div class="select_tab">定时任务日志</div>
          </div>
        </template>
      </header-tabs>

      <div class="middleBox">
        <search-box>
          <template slot="right">
            <Button type="primary" @click="back">返回</Button>
          </template>
        </search-box>

        <v-table :loading="pageConfig.loading" border :columns="logColumns" :data="list">
          <template slot-scope="{ row }" slot="status">
            <span>{{logStatus.find((item)=>item.value===row.status).key}}</span>
          </template>
        </v-table>

        <v-page :pageConfig="pageConfig" @refresh="getList"></v-page>
      </div>
    </div>
  </div>
</template>

<script>
import {logColumns, pageConfig, logStatus} from "./pageConfig";

export default {
  name: 'TimingTaskLog',

  data() {
    return {
      logColumns,
      pageConfig,
      logStatus,
      list: [],
      searchParams: {
        jobId: this.$route.params.jobId
      },
    };
  },

  mounted() {
    this.getList(this.pageConfig);
  },

  methods: {
    back(){
      this.$router.back();
    },
    // 获取列表
    getList(page){
      this.pageConfig.loading = true;
      this.$api.get("sp/sys/scheduleLog/list", {
        params: {
          page: page.pageNow,
          limit: page.pageSize,
          ...this.searchParams,
        }
      }).then((res)=>{
        if(res.data.code === 0){
          this.list = res.data.page.list;
          this.pageConfig.total = res.data.page.totalCount;
        }
      }).finally(()=>{
        this.pageConfig.loading = false;
      });
    },

    // 搜索
    search(){
      this.pageConfig.pageNow = 1;
      this.getList(this.pageConfig);
    },
  }
};
</script>

<style scoped lang="less">
</style>